{set:$user_id = $this->user['user_id']}
{query:name=member where=user_id eq $user_id items=$users/}
{set:$user = $users[0];}
<div class="main f_r">

	{set:$msg_ids = strlen($user['message_ids'])>=2?substr($user['message_ids'],0,-1):0;}
    {query:fields= count(id) as num name=message where=id in($msg_ids)/}
    {set:$num = isset($items[0]['num'])?$items[0]['num']:0}
    {if:$num>0}
    <div class="prompt m_10">
        <b>温馨提示：</b>您有<span class="red">{$num}</span> 条站内未读短信息，<a class="blue" href="{url:/ucenter/message}">现在去看看</a>
    </div>
    {/if}

	<div class="userinfo_bar"><span class="f_r">上一次登录时间：{$user['last_login']}</span><b class="f14">您好，{$this->user['username']} 欢迎回来!</b></div>
	<div class="box clearfix">
		<h3>用户信息</h3>
		<dl class="userinfo_box">
			<dt>
			{set:$user_ico = $this->user['head_ico']}
			<a class="ico"><img id="user_ico_img" src="{webroot:$user_ico}" width="100" height="100" alt="" onerror="this.src='{skin:images/front/user_ico.gif}'" /></a>
			<a class="blue" href="javascript:select_ico();">修改头像</a>
			</dt>
			<dd>
			<table width="100%" cellpadding="0" cellspacing="0">
				<col width="192px" />
				<col width="120px" />
				<col width="192px" />
				<col />
				<tr>
					<td>你的账户目前总积分：<b class="red2">{$user['point']}</b></td>
					<td><a class="blue" href="{url:/ucenter/integral}">查看积分历史</a></td>
					{query:fields=sum(order_amount) as amount,count(id) as num name = order where=user_id eq $user_id and pay_status eq 1/}
					{set:$amount = isset($items[0]['amount'])?$items[0]['amount']:0.00;$num = isset($items[0]['num'])?$items[0]['num']:0}
					<td>你的订单交易总数量：<b class="red2">{$num}</b> 笔</td>
					<td><a class="blue" href="{url:/ucenter/order}">进入订单列表</a></td>
				</tr>
				<tr>

					<td>总消费额：<b>￥</b><b class="red2">{$amount}</b></td>
					<td></td>
					<td>预存款余额：<b>￥</b><b class="red2">{$user['balance']}</b></td>
				</tr>
				<tr>
					{set:$prop = strlen($user['prop'])>2?substr($user['prop'],1,-1):0;}
					{query:fields=count(id) as num name=prop where= id in ($prop) and type eq 0/}
					{set:$num=isset($items[0]['num'])?$items[0]['num']:0;}
					<td>代金券：拥有可用代金券 <b class="red2">{$num}</b> 张</td>
					<td></td>
				</tr>
			</table>
			<div class="stat">
				{query:fields=count(id) as num name=comment where=user_id eq $user_id and status eq 0/}
				{set:$num=isset($items[0]['num'])?$items[0]['num']:0;}
				<span>待评价商品：<label>(<b class="red2">{$num}</b>)</label></span>
				{query:fields=count(id) as num name=order where=user_id eq $user[user_id] and status eq 1/}
				{set:$num = isset($items[0]['num'])?$items[0]['num']:0}
				<span>待付款订单：<label>(<b class="red2">{$num}</b>)</label></span>
				{query:fields=count(id) as num name=order where=user_id eq $user[user_id] and status eq 2 and distribution_status eq 1/}
				{set:$num = isset($items[0]['num'])?$items[0]['num']:0}
				<span>待确认收货：<label>(<b class="red2"><a href="{url:/ucenter/order}">{$num}</b>)</a></label></span>
			</div>
			</dd>
		</dl>
	</div>
	<h3 class="bg">我的订单</h3>
	<div class="box m_10">
		<table class="list_table" width="100%" cellpadding="0" cellspacing="0">
			<col width="140px" />
			<tr>
				<th>订单编号</th><th>下单日期</th><th>收货人</th><th>支付方式</th><th>总金额</th><th>订单状态</th>
			</tr>

			{query:name=order where=user_id eq $user[user_id] and if_del eq 0 order=id desc limit=6}
			<tr>
				<td><a href="{url:/ucenter/order_detail/id/$item[id]}">{$item['order_no']}</a></td><td>{$item['create_time']}</td><td>{$item['accept_name']}</td><td>{$this->payments[$item['pay_type']]['name']}</td><td>￥{echo:($item['order_amount'])}</td><td>
					{if:$item['status']==1}
					{if:$item['pay_type']==0}
					<b class="orange">等待确认</b>
					{else:}
					<b class="orange">等待付款</b>
					{/if}
					{elseif:$item['status']==2}
					{if:$item['distribution_status']==1}
					<b class="green">已发货</b>
					{else:}
					<b class="orange">等待发货</b>
					{/if}
					{elseif:$item['status']==3 || $item['status']==4}
					<b class="green">已取消</b>
					{elseif:$item['status']==5}
					<b class="green">已完成</b>
					{if:$item['pay_status']==2}
					<b class="green">已退款</b>
					{elseif:$item['pay_status']==3}
					<b class="green">已申请退款</b>
					{/if}
					{if:$item['distribution_status']==2}
					<b class="green">已退货</b>
					{elseif:$item['distribution_status']==3}
					<b class="green">已申请退货</b>
					{/if}
					{/if}
				</td>
			</tr>
			{/query}

			<tfoot><tr><td colspan="6" class="t_r"><a class="blue" href="{url:/ucenter/order}">更多订单&gt;&gt;</a></td></tr></tfoot>
		</table>
	</div>
	<div class="box">
		<div class="title"><h2>也许你会对下列商品感兴趣</h2></div>
		<div class="cont clearfix">
			<ul class="prolist f_l">
				{query:name=goods where=id in( select goods_id from commend_goods where commend_id eq 4 ) and is_del eq 0 limit=12}
				<li>
				<a href="{url:/site/products/id/$item[id]}" target="_black"><img src="{webroot:$item[list_img]}" alt="{$item['name']}" height="100" width="100"></a>
				<p class="pro_title"><a href="{url:/site/products/id/$item[id]}" target='_black'>{$item['name']}</a></p>
				<p class="price_new"><b>￥{$item['sell_price']}</b></p>
				</li>
				{/query}
			</ul>
		</div>
	</div>
</div>
<script type='text/javascript'>
//选择头像
function select_ico()
{
	{set:$callback = urlencode('/ucenter/user_ico_upload')}
	art.dialog.open('{url:/block/photo_upload/callback/$callback}',{id:'user_ico',title:'设置头像'});
}

//头像上传回调函数
function callback_user_ico(content)
{
	var content = eval(content);
	if(content.isError == true)
	{
		alert(content.message);
	}
	else
	{
		$('#user_ico_img').attr('src',content.data);
	}
	art.dialog({id:'user_ico'}).close();
}
</script>
